16. Improve Your Model

Improve Your Model

You may have noticed that your confusion matrices look more like this… highly confused! This is because you haven't actually generated meaningful features yet. To get better features, open up the features.py script in /sensor_stick/src/sensor_stick/ (this might seem like a weird directory structure but this is the preferred ROS way of setting up your internal Python packages). In this script you'll find two functions called compute_color_histograms() and compute_normal_histograms().

Histogram Features

Have a look at the compute_color_histograms() and compute_normal_histograms()functions in features.py. What's wrong with the features being output by these functions?

SOLUTION: There are no histograms! We're outputting random junk!

Inside each of the compute_color_histograms() and compute_normal_histograms() functions you'll see there are three lists of values that have been extracted from your point cloud, channel_*_vals for color and norm_*_vals for normals. You can bin these up using the same histogram techniques you saw in the previous exercises. After binning up into histograms, concatenate them into a feature vector and normalize to create your function output (normed_features).

Try running capture_features.py and train_svm.py again to see if you're doing better!

Improving training data

If everything worked out your model should be making improved predictions on the training set. What other things could you do to improve the performance of your model?

SOLUTION:
  • Compute features for a larger set of random orientations of these objects
  • Convert RGB data to HSV
  • Try different binning schemes with the histograms
  • Modify the SVM parameters (kernel, regularization etc.)

Improvements

To modify how many times each object is spawned randomly, look for the for loop in capture_features.py that begins with for i in range(5):. Increase this value to increase the number of times you capture features for each object.

To use HSV, find the line in capture_features.py where you're calling compute_color_histograms() and change the flag to using_hsv=True.

To mess with the SVM parameters, open up train_svm.py and find where you're defining your classifier. Check out the sklearn.svm docs to see what your options are there.